﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Common;
using PCSWpfData;

namespace PCSWpfClient.Commands
{
    class InstrumentDataTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate  SelectTemplate(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null && item is Instrument)
            {
                Instrument instrument = item as Instrument;

                if (instrument.Active)
                    return
                        element.FindResource("InstrumentTemplate") as DataTemplate;
                else
                    return
                        element.FindResource("InactiveInstrumentTemplate") as DataTemplate;
            }

            return null;

        }

    }
}
